<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /**
         * let 命令
         * 
         * 1. 块级作用域 (区分: 全局变量和局部变量) 只有在{}内有效，与function无关
        */
        if (true) {
            var a = 1;
            let b = 2
            console.log(b); //2
        }
        console.log(a); //1
        // console.log(b); //not defined
        // console.log(c); //not defined 即未声明也未赋值


        /***
         * 区分: 全局变量和局部变量
         * 在function中是否使用var声明！！
        */

        var age = 12;
        let name = 'tt';
        
        if(true) {
            console.log(age, name);
        }
    </script>
</head>

<body>

</body>

</html>